// webpack.config.js
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const path = require('path')
module.exports = {
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: [
        path.join(__dirname, './src/assets/styles/variables.less'),
        path.join(__dirname, './src/assets/styles/mixins.less')
      ]
    }
  },
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.mjs$/,
          include: /node_modules/,
          type: "javascript/auto"
        },
      ]
    },
    plugins: [
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
    devServer: {
      proxy: {
        '/api': {
          target: 'http://pcapi-xiaotuxian-front-devtest.itheima.net/', //接口域名
          changeOrigin: true,       //是否跨域
          pathRewrite: {         //路径重置
            '^/api': ''
          }
        }
      }
    },
    externals: {
      qc: 'QC'
    }
  },
  // 这个是给webpack-dev-server开启可IP和域名访问权限。
  chainWebpack: config => {
    config.devServer.disableHostCheck(true)
  }
}
